import React from 'react';
import ReactDOM from 'react-dom';
import {createStore, applyMiddleware, compose} from 'redux';
import thunk from 'redux-thunk';
import {Provider} from 'react-redux';
import {BrowserRouter, Route, Redirect, Switch} from 'react-router-dom';
import reducers from './reducer';
import './config';
import './index.css';
import Login from "./container/login/login";
import Home from "./container/home/home";
import Register from "./container/register/register";
import Data from "./test";
import AuthRoute from "./component/authroute/authroute";
import Main from "./container/main/main";

const store = createStore(reducers, compose(
    applyMiddleware(thunk),
    window.devToolsExtension ? window.devToolsExtension() : f => f
));

ReactDOM.render(
    (
        <Provider store={store}>
            <BrowserRouter>
                <Switch>
                    <div>
                        <AuthRoute/>
                        <Route path='/' exact component={Home}/>
                        <Route path='/main' component={Main}/>
                        <Route path='/login' component={Login}/>
                        <Route path='/register' component={Register}/>
                        <Route path='/data' component={Data}/></div>
                </Switch>
            </BrowserRouter>
        </Provider>
    ),
    document.getElementById('root')
);
